Public Class CaseItem
    Inherits RtfTabStripItem

    Private WithEvents m_objCase As MyCase

    Public CurrentSection As Integer
    Public CurrentRegion As Integer = 1

    Public Sub New(Optional ByVal title As String = "")
        MyBase.New(title)
    End Sub

    Public ReadOnly Property Data() As MyCase
        Get
            Return m_objCase
        End Get
    End Property

    Public Overrides Sub OnItemAdded()
        Me.ReadOnly = True
        m_objCase = New MyCase
        If Me.Title.Length > 0 Then m_objCase_SectionChanged()
    End Sub


    Private Sub m_objCase_Building(ByVal msg As String) Handles m_objCase.Building
        MyBase.ConsoleInfo += msg + Environment.NewLine
    End Sub

    Private Sub m_objCase_FileChanged() Handles m_objCase.FileChanged
        If m_objCase.File IsNot Nothing Then MyBase.Title = My.Computer.FileSystem.GetName(m_objCase.File)
    End Sub

    Private Sub m_objCase_SectionChanged() Handles m_objCase.SectionChanged
        MyBase.Rtf = m_objCase.Sections.ReadRtf
    End Sub

End Class
